package com.xueyi.system.batchManager.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.xueyi.common.core.constant.basic.SqlConstants;
import com.xueyi.system.batchManager.domain.po.BatchManagerPo;
import com.xueyi.system.batchManager.domain.query.BatchManagerQuery;
import com.xueyi.system.batchManager.domain.dto.BatchManagerDto;
import com.xueyi.system.batchManager.mapper.BatchManagerMapper;
import com.xueyi.system.batchManager.service.IBatchManagerService;
import com.xueyi.system.batchManager.manager.IBatchManagerManager;
import com.xueyi.common.web.entity.service.impl.BaseServiceImpl;
import com.xueyi.system.packingManage.domain.po.PackingManagePo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 生产批次管理 服务层处理
 *
 * @author zlf
 */
@Service
public class BatchManagerServiceImpl extends BaseServiceImpl<BatchManagerQuery, BatchManagerDto, IBatchManagerManager> implements IBatchManagerService {


    @Autowired
    private BatchManagerMapper batchManagerMapper;
    /**
     * 查询生产批次对象列表 | 数据权限 | 附加数据
     *
     * @param batchManager 生产批次对象
     * @return 生产批次对象集合
     */
    @Override
    //@DataScope(userAlias = "createBy", mapperScope = {"BatchManagerMapper"})
    public List<BatchManagerDto> selectListScope(BatchManagerQuery batchManager) {
        return baseManager.selectListExtra(batchManager);
    }

    @Override
    public BatchManagerPo getBatchInfo(String batch) {
        QueryWrapper<BatchManagerPo> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("batch_code",batch);
        queryWrapper.last(SqlConstants.LIMIT_ONE);
        BatchManagerPo batchManagerPo = batchManagerMapper.selectOne(queryWrapper);
        return batchManagerPo;
    }
}
